package com.hilin.entity.po;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.hilin.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;

/**
 * @author qhl
 * @since 2021-11-24
 */
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Data
@ApiModel("用户表")
@TableName("account_info")
public class AccountInfoPo extends BaseEntity<AccountInfoPo> {

    @ApiModelProperty("用户ID;系统生成，全平台唯一")
    @TableId(value = "account", type = IdType.AUTO)
    private Long account;
    @ApiModelProperty("用户ID;业务层指定，同一个机构唯一")
    @TableField("account_id")
    private String accountId;
    @ApiModelProperty("用户名称")
    @TableField("account_name")
    private String accountName;
    @ApiModelProperty("手机号")
    private String mobile;
    @ApiModelProperty("密码;生成规则：md5大写(md5大写（密码）+盐)")
    private String password;
    @ApiModelProperty("盐")
    private String salt;
    @ApiModelProperty("所在机构id")
    @TableField("org_id")
    private Long orgId;
    @ApiModelProperty("所在部门id")
    @TableField("dept_id")
    private String deptId;
    @ApiModelProperty("创建人")
    private String creator;
    @ApiModelProperty("创建时间")
    @TableField("creator_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date creatorTime;
    @ApiModelProperty("更新人")
    private String updator;
    @ApiModelProperty("更新人类型")
    @TableField("updator_type")
    private String updatorType;
    @ApiModelProperty("更新时间")
    @TableField("updator_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date updatorTime;

    @ApiModelProperty("认证字符串")
    @TableField(exist = false)
    private String token;
    @ApiModelProperty("认证字符串添加的随机字符串，避免每次生成token都一样")
    @TableField(exist = false)
    private String tokenRandomStr;

    public static String genAccountName() {
        return "RandomUtils";
    }
}